<template>
	<view class="a-page">
		<a-nav-bar>
			<q-btn color="primary" label="新增商品" @click="store.增" />
			<q-btn color="negative" label="清缓存" @click="store.清缓存" v-if="a.是调试" />
		</a-nav-bar>
		<uni-list>
			<uni-list-item class="fit" v-for="(item,index) in 单项组" :key="item.id">
				<template v-slot:body>
					<view class="row justify-between fit  no-wrap">
						<view class="row justify-between q-gutter-md">
							<a-ziduan :编辑="取编辑(item)" :单项="item" 字段名="名称" :ref="(el) => setInputRef(el, item)" />
							<!-- <a-ziduan v-model="item.名称" 标题="名称" :编辑="取编辑(item)" :ref="(el) => setInputRef(el, item)" /> -->
							<a-ziduan :编辑="取编辑(item)" :单项="item" 字段名="价格" 类型="人民币" width="150" />
							<a-ziduan :编辑="取编辑(item)" :单项="item" 字段名="单位" width="200" :可添加="true" :候选值="设置.单位候选值组" />
						</view>
						<view class="q-gutter-y-md column a-w-100 flex-center q-pl-sm">
							<button type="primary" @click="store.改(item)" size="mini" plain v-if="!取编辑(item)">改</button>
							<button type="primary" @click="store.确定(item)" size="mini" plain v-if="取编辑(item)">✔</button>
							<button type="warn" @click="store.删(item)" size="mini" plain>删</button>
						</view>
					</view>
				</template>
			</uni-list-item>
		</uni-list>
		<view class="row flex-center q-pa-lg" v-if="单项组.length==0">
			还没有数据，点击添加👆
		</view>
	</view>
</template>

<script setup>
	import { computed } from "vue"
	import usestore from "./store.js"
	const store = usestore()
	const { 单项组, 单项集, setInputRef, 取编辑 ,a} = store

	import useshezhistore from "@/stores/shezhi-store"
	const shezhi = useshezhistore()
	const { a: 设置 } = shezhi
</script>

<style>

</style>